'''
@Company: TWL
@Author: xue jian
@Email: xuejian@kanzhun.com
@Date: 2020-01-16 18:07:40
'''
import os
import sys
import json
sys.path.append(os.path.abspath(os.path.join(os.path.dirname('__file__'), os.path.pardir)))

import thrift
from thrift.transport import TSocket
from thrift.transport import TTransport
from thrift.protocol import TBinaryProtocol
from hulk_proxy.HulkProxyServ import Client
from scan_data.ttypes import ScanData

__HOST = "172.21.32.54"
__PORT = 10066

try:
    tsocket = TSocket.TSocket(__HOST, __PORT)
    transport = TTransport.TFramedTransport(tsocket)
    protocol = TBinaryProtocol.TBinaryProtocol(transport)
    client = Client(protocol)

    transport.open()

    # f_meta = open('./ps_meta/deepfm.meta')
    # meta_cont = f_meta.read()
    # f_meta.close()
    # client.hpush('for_test', 'meta', meta_cont)
    # client.hpush('for_test1', 'meta', meta_cont)
    # client.hpush('gust_1234', 'meta', meta_cont)
    # client.hpush('gust_1122', 'meta', meta_cont)

    # f_meta = open('./ps_meta/success_deepfm_id.meta')
    client.expire(30*24*60*60)
    f_meta = open('/data1/xuejian/sync/model_zoo/models/cascade/example.meta')
    meta_cont = f_meta.read()
    f_meta.close()
    client.hpush('flash_example_1', 'meta', meta_cont)


    # f_net = open('./ps_meta/success_deepfm_id.net')
    f_net = open('/data1/xuejian/sync/model_zoo/models/cascade/example.net')
    net_cont = f_net.read()
    f_net.close()
    client.hpush('flash_example_1', 'layer', net_cont)




    # res = client.hget('for_test', 'meta')
    # print(res)

    
    


    transport.close()
except thrift.TException as ex:
    print(ex.message)